package demo;

import java.util.Scanner;
import java.util.concurrent.TimeUnit;

public class InterruptedDemo {

    static class subThread extends Thread{

        @Override
        public void run() {
            try{
                while(true){
                    System.out.println("A");
                    TimeUnit.SECONDS.sleep(10);
                    boolean interrupted=Thread.interrupted();
                    if(interrupted){
                        break;
                    }
                }
            }catch( InterruptedException ignored){

            }



        }
    }

    public static void main(String[] args) {

        subThread t=new subThread();
        t.start();
        Scanner sc=new Scanner(System.in);
        sc.nextLine();
        t.interrupt();

    }
}
